Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for optional Kafka properties from external file #8743

Merged
merged 1 commit into from
Apr 11, 2022

Conversation

klDen
Copy link
Member

@klDen klDen commented Aug 1, 2021

Solves #6439 and #8197

@cla-bot cla-bot bot added the cla-signed label Aug 1, 2021
@klDen klDen requested a review from kokosing August 1, 2021 13:54
Copy link
Member

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are missing. Can you please add a case where configuration from resource file is used and we can see the changed behavior from tests?

@klDen klDen force-pushed the feature/kafka-config branch 5 times, most recently from 100e9a8 to ee0927e Compare August 4, 2021 03:43
Copy link
Member

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to come up with a testing, to make sure that it is actually used in all places? Do you have any idea how it can be tested?

@klDen
Copy link
Member Author

klDen commented Aug 6, 2021

We need to come up with a testing, to make sure that it is actually used in all places? Do you have any idea how it can be tested?

Hello @kokosing ! Yes, I'm currently in the process of implementing a new product test and let the tests utilize the new config.

@kokosing
Copy link
Member

kokosing commented Aug 6, 2021

I does have to be a product test. Maybe an unit test?

Copy link
Member

@charlesjmorgan charlesjmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have tests that use actual values in the external resource configs so that we can understand how they interact with the different security protocols and trino config options.

@klDen klDen force-pushed the feature/kafka-config branch from ee0927e to 4ad54c1 Compare August 7, 2021 23:57
@klDen
Copy link
Member Author

klDen commented Aug 8, 2021

I does have to be a product test. Maybe an unit test?

I was thinking of having a product test that runs purely on DefaultTextConfig. I'm open for suggestions to implement tests differently! I agree that adding unnecessarily a new product test can increase overall build time.

If we want to go forward with Unit tests, perhaps I can add 2 new tests in TestKafkaPlugin:

  1. No security protocol defined in kafka.properties, but defined in resource.config.properties;
  2. kafka.security-protocol=PLAINTEXT defined in kafka.properties with unmanaged Kafka configs by Trino in resource.config.properties.

WDYT @kokosing ?

@klDen klDen force-pushed the feature/kafka-config branch 3 times, most recently from 5c6d725 to b49cac1 Compare August 8, 2021 00:12
@klDen klDen requested a review from kokosing August 8, 2021 00:41
@klDen klDen force-pushed the feature/kafka-config branch 2 times, most recently from 4c48b79 to 057628b Compare August 8, 2021 02:23
@klDen klDen requested a review from charlesjmorgan August 8, 2021 02:25
@klDen klDen force-pushed the feature/kafka-config branch 3 times, most recently from 13df6f8 to 8911101 Compare August 11, 2021 02:31
@gsvlad
Copy link

gsvlad commented Nov 8, 2021

Hi! In our project we use Confluent and want to produce from Trino to its topics. Confluent supports SASL method of authentication, so we are interested in this PR. Are there any blockers for it be released?

@klDen klDen force-pushed the feature/kafka-config branch 3 times, most recently from 3f26668 to 12793f4 Compare December 1, 2021 05:48
Copy link

@matt12eagles matt12eagles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are working for me! Very cool klDen!

@matt12eagles
Copy link

@kokosing any chance you can get this approved and push it in?? :) would love to have this in the official builds. Thanks!

@matt12eagles
Copy link

We are waiting for this as well... Any update here team?

@JackPott
Copy link

I note there are a huge number of open PRs, how long do reviews and merges usually take?

Copy link
Member

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase. It is looks nice. Just few comments.

@matt12eagles
Copy link

Hi All! Any updates here?? I'm not exactly sure who we are waiting for at this point. Thanks team!

@klDen
Copy link
Member Author

klDen commented Mar 10, 2022

Hi All! Any updates here?? I'm not exactly sure who we are waiting for at this point. Thanks team!

Hey. I'll resolve the remaining comments this Sunday.

@@ -38,19 +40,30 @@ private void installClientModule(SecurityProtocol securityProtocol, Module modul
{
install(conditionalModule(
KafkaSecurityConfig.class,
config -> config.getSecurityProtocol().equals(securityProtocol),
config -> config.getSecurityProtocol().orElse(null) == securityProtocol,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use Optional#filter(SecurityProtocol::equals).isPresent()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applying this fails TestKafkaPlugin tests since securityProtocol is nullable and calling security::equals throws NullPointerException.

@@ -27,12 +28,11 @@

public class KafkaSecurityConfig
{
private SecurityProtocol securityProtocol = PLAINTEXT;
private SecurityProtocol securityProtocol;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have here as Optional<SecurityProtocol> ?

Copy link
Member Author

@klDen klDen Mar 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting it as Optional<SecurityProtocol> breaks the unit test since it expects an Optional.empty and actual is null.

public class TestKafkaSecurityConfig
{
    @Test
    public void testDefaults()
    {
        assertRecordedDefaults(recordDefaults(KafkaSecurityConfig.class)
                .setSecurityProtocol(null));

The signature public KafkaSecurityConfig setSecurityProtocol(SecurityProtocol securityProtocol) accepts a plain SecurityProtocol object and not an Optional<SecurityProtocol> one.

@klDen klDen force-pushed the feature/kafka-config branch 4 times, most recently from 34bb045 to fde302c Compare March 14, 2022 06:38
@klDen klDen requested a review from kokosing March 14, 2022 07:02
@klDen klDen force-pushed the feature/kafka-config branch 2 times, most recently from 0eca91c to 9bb94b3 Compare March 15, 2022 06:47
@klDen klDen requested a review from Praveen2112 March 15, 2022 06:49
@klDen klDen force-pushed the feature/kafka-config branch from 9bb94b3 to 0a37bb9 Compare March 16, 2022 03:20
@klDen
Copy link
Member Author

klDen commented Mar 16, 2022

The failing ci maven-checks is unrelated to my changes:

2022-03-16T06:45:25.760Z	ERROR	main	io.trino.server.Server	io.trino.spi.Plugin: Provider io.trino.plugin.deltalake.DeltaLakePlugin not found
java.util.ServiceConfigurationError: io.trino.spi.Plugin: Provider io.trino.plugin.deltalake.DeltaLakePlugin not found
	at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:589)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1212)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1221)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1265)
	at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1300)
	at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1385)
	at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:275)
	at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:239)
	at io.trino.server.PluginManager.loadPlugin(PluginManager.java:166)
	at io.trino.server.PluginManager.loadPlugin(PluginManager.java:157)
	at io.trino.server.ServerPluginsProvider.lambda$loadPlugins$1(ServerPluginsProvider.java:58)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31)
	at java.base/java.util.concurrent.ExecutorCompletionService.submit(ExecutorCompletionService.java:184)
	at io.trino.util.Executors.executeUntilFailure(Executors.java:41)
	at io.trino.server.ServerPluginsProvider.loadPlugins(ServerPluginsProvider.java:53)
	at io.trino.server.PluginManager.loadPlugins(PluginManager.java:137)
	at io.trino.server.Server.doStart(Server.java:126)
	at io.trino.server.Server.lambda$start$0(Server.java:80)
	at io.trino.$gen.Trino_c116fb3____20220316_064516_1.run(Unknown Source)
	at io.trino.server.Server.start(Server.java:80)
	at io.trino.server.TrinoServer.main(TrinoServer.java:38)


🚨 Failed to execute a query after Trino container started
4d094b0ad9bc0319bdf797e2e0c6557378b8abc3d65fc6fee44f031c64fb3c20
Error: Process completed with exit code 1.

Copy link
Member

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase and squash commits. There is also last comment from me.

@klDen klDen force-pushed the feature/kafka-config branch from 0a37bb9 to be4b572 Compare March 31, 2022 07:35
@klDen
Copy link
Member Author

klDen commented Mar 31, 2022

Please rebase and squash commits. There is also last comment from me.

Squashed!

@kokosing
Copy link
Member

kokosing commented Apr 3, 2022

@Praveen2112 or @lukasz-walkiewicz do you want to take a look?

@kokosing kokosing merged commit 910501b into trinodb:master Apr 11, 2022
@kokosing
Copy link
Member

Merged, thanks!

@kokosing kokosing mentioned this pull request Apr 11, 2022
@github-actions github-actions bot added this to the 377 milestone Apr 11, 2022
@hashhar
Copy link
Member

hashhar commented Aug 10, 2022

The external file doesn't support referencing secrets since it's not passed through via Bootstrap probably.

Not sure if this can be implemented however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

support sasl auth properties options to kafka connector
9 participants